<!-- 视图比例尺 -->

<template>
  <div class="Secure-MapView-ruler" :data-name="map_info.mapName">{{ ruler }}米</div>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import props from './props'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'ViewRuler',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [CORE.mixInfo('map', 'map_')],

  /**
   * 属性注册 (抽取以便查阅)
   */
  props,

  /**
   * 计算属性 (慎用箭头函数)
   */
  computed: {
    /**
     * 比例尺
     */
    ruler() {
      const { map_info: { rateBefore, rateAfter }, $parent: { scale = 1 } } = this
      const ruler = 100 * rateAfter / rateBefore / scale
      return isNaN(ruler) ? '' : +ruler.toFixed(2)
    },
  },
}
</script>
